#define _CRT_SECURE_NO_WARNINGS

#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

typedef struct TPoint {
	int x, y, idx;
	TPoint(int a=0, int b=0, int c=0){x = a; y = b; idx = c;}
} Point;

typedef struct TShape {
	Point vert[1000];
	int vNum;

	void show(void) {
		cout << "vNum: " << vNum << endl;
		for (int i=0; i<vNum; ++i)
			cout << vert[i].x << " " << vert[i].y << " " << vert[i].idx << endl;
	}
} Shape;

char name[40];
Point center;
Shape orgShape;
bool appeared[1000];

inline Point operator-(Point a, Point b) {return Point(a.x-b.x, a.y-b.y);}

bool turnRight(Point x, Point y, Point z) {
	Point yx = y - x;
	Point zy = z - x;
	int cross = yx.x*zy.y - yx.y*zy.x;
	return cross<=0;
}

Shape calConvex(Shape inShape) {
	Shape midConvex;
	int &vNum = midConvex.vNum;
	vNum = 0;

	for (int i=0; i<inShape.vNum; ++i)
		inShape.vert[i+inShape.vNum] = inShape.vert[i];

	for (int i=0; i<2*inShape.vNum; ++i) {
		while (vNum>=2 && 
				turnRight(midConvex.vert[vNum-2], midConvex.vert[vNum-1], inShape.vert[i])) {
			--vNum;
		}
		midConvex.vert[vNum++] = inShape.vert[i];
	}

	Shape retConvex;
	retConvex.vNum = 0;
	memset(appeared, 0, sizeof(bool)*(inShape.vNum+1));
	for (int i=0; i<vNum; ++i) {
		if (appeared[midConvex.vert[i].idx])
			retConvex.vert[retConvex.vNum++] = midConvex.vert[i];
		appeared[midConvex.vert[i].idx] = true;
	}

	return retConvex;
}

inline int dotProduct(Point a, Point b) {
	return a.x*b.x + a.y*b.y;
}

bool aboveEdge(Point x, Point y, Point c) {
	Point cx = c - x;
	Point yx = y - x;
	Point cy = c - y;
	Point xy = x - y;
	if (dotProduct(cx, yx)>0 && dotProduct(cy, xy)>0)
		return true;
	else
		return false;
}

int main(void)
{
	while (true) {
		scanf(" %s", name);
		if (strlen(name) == 1 && name[0] == '#')
			break;
		cout.width(20);
		cout << left << name;
		scanf("%d%d", &center.x, &center.y);
		orgShape.vNum = 0;
		int &vNum = orgShape.vNum;
		while (true) {
			scanf("%d%d", &orgShape.vert[vNum].x, &orgShape.vert[vNum].y);
			if (orgShape.vert[vNum].x == 0 && orgShape.vert[vNum].y == 0) {
				break;
			}
			orgShape.vert[vNum].idx = vNum+1;
			++vNum;
		}

		Shape cvxShape = calConvex(orgShape);
//		cvxShape.show();

		cvxShape.vert[cvxShape.vNum] = cvxShape.vert[0];
		for (int i=0; i<cvxShape.vNum; ++i) {
			if (aboveEdge(cvxShape.vert[i], cvxShape.vert[i+1], center)) {
				cout << max(cvxShape.vert[i].idx, cvxShape.vert[i+1].idx) << endl;
				break;
			}
		}

	}

	return 0;
}